
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@page import="java.sql.*,java.io.*"%>
<%
HttpSession hs= request.getSession();
String uid=(String)hs.getAttribute("id");
//int userid=Integer.parseInt(uid);
try
{
	//MakeConnection mc=new MakeConnection();
	InputStream sImage;   
	//Connection con=mc.getCon();
	Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/kbcssdb", "root", "mysql");
	PreparedStatement pstmt=con.prepareStatement("SELECT PIC FROM IMAGE WHERE USERID=?");
	ResultSet rs=null;
	pstmt.setString(1,uid);
	rs=pstmt.executeQuery();
	if(rs.next()){
	    byte[] bytearray = new byte[1048576];
	    int size=0;
	    sImage = rs.getBinaryStream(1);
	    response.reset();
	    response.setContentType("image/jpeg");
	    while((size=sImage.read(bytearray))!= -1 ){
	    response.getOutputStream().write(bytearray,0,size);
	 }
	}
con.close();
}catch(Exception e)
{
	
}
%>
